package com.iwdnb.gkgz.application.event;

import java.util.List;

import com.alibaba.fastjson.JSONObject;

import com.google.common.collect.Table;
import com.iwdnb.bmnf.common.eventbus.EventHandler;
import com.iwdnb.gkgz.application.service.StockPredictionService;
import com.iwdnb.gkgz.common.model.dto.StockDayData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class DynamicPredictionEventHandler implements EventHandler<JSONObject> {
    public static final String TOPIC_DYNAMIC_PREDICTION = "dynamicPrediction";
    @Autowired
    private StockPredictionService stockPredictionService;

    @Override
    public String topic() {
        return TOPIC_DYNAMIC_PREDICTION;
    }

    @Override
    public void onMessage(JSONObject message) {
        int begin=message.getInteger("begin");
        String sort = message.getString("sort");
        Table<String, String, List<StockDayData>> table = (Table<String, String, List<StockDayData>>)message.get(
            "table");
        stockPredictionService.dynamicPrediction(begin,sort, table);
    }
}
